package com.face.server.repository;

import com.face.server.entity.CameraLog;
import com.face.server.entity.EventLog;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.Date;
import java.util.List;

public interface CameraLogRepository extends MongoRepository<CameraLog, String> {

    @Query("{\n" +
            "\t$and:[\n" +
            "\t\t{date: {$gte:?0, $lte: ?1}},\n" +
            "\t\t {$or: \n" +
            "\t \t\t[{buildNum: ?2}, {adminUsername:{$regex: ?3, $options: 'i'}}, {event:?4}]\n" +
            "\t \t}\n" +
            "\t]\n" +
            "}")
    List<CameraLog> findBy(Date begin, Date end, String build, String name, boolean event, Pageable pageable);
}
